#ifndef __SIG_HANDLERS_H__
#define __SIG_HANDLERS_H__

#include <gtk/gtk.h>
#include "qaholom.h"

////////////////////////////////////////////////////////////////////////////
// RAW SIGNAL DEFINITION

#define INNER_DECL_SIGNAL_HANDLER(SIGHANDLER, EVENT, EVENTTYPE, SIGMEMFUNC)\
template <typename T> class SIGMEMFUNC##SIG_HANDLER\
{\
public:\
   static gboolean SIGMEMFUNC(GtkWidget* widget, EVENTTYPE* event, gpointer data)\
   { return reinterpret_cast<T*>(data)->SIGMEMFUNC(event); }\
};\
\
template<typename T> void SIGHANDLER(T& widget)\
{\
   g_signal_connect(GTK_WIDGET(widget.egoWidget), \
                    EVENT,\
                    G_CALLBACK(SIGMEMFUNC##SIG_HANDLER<T>::SIGMEMFUNC),\
                    &widget);\
}\

/////////////////////////////////////////////////////////////////////////
// SIGNAL HANDLER TYPE DEFINITION

#define DECL_SIGNAL_HANDLER_T1(S,E,M) INNER_DECL_SIGNAL_HANDLER(S, E, GdkEventButton, M)
#define DECL_SIGNAL_HANDLER_T2(S,E,M) INNER_DECL_SIGNAL_HANDLER(S, E, GdkEventKey, M)
#define DECL_SIGNAL_HANDLER_T3(S,E,M) INNER_DECL_SIGNAL_HANDLER(S, E, GdkEventExpose, M)


/////////////////////////////////////////////////////////////////////////
// PUBLIC SIGNAL HANDLER DEFINITION

// TYPE1 : (GtkWidget*, GdkEventButton*, pointer)
DECL_SIGNAL_HANDLER_T1(ON_BUTTON_PRESSED, "button-press-event",  onButtonPressed)
DECL_SIGNAL_HANDLER_T1(ON_MOUSE_MOVED,    "motion-notify-event", onMouseMoved)
// TYPE2 : (GtkWidget*, GdkEventKey*, pointer)
DECL_SIGNAL_HANDLER_T2(ON_KEY_PRESSED,    "key-press-event",     onKeyPressed)
// TYPE3 : (GtkWidget*, GdkEventExpose*, pointer)
DECL_SIGNAL_HANDLER_T3(ON_EXPOSE,         "expose-event",        onExpose)









#endif
